import { get } from 'lodash-es'

export class DepositRule {
  id?: string
  hotel_id?: string
  code?: string
  name?: string
  rule_type?: string
  amount?: number
  disabled?: boolean
  sequence?: number
  created_id?: string
  updated_id?: string
  created_at?: string
  updated_at?: string
  version?: number;
  [key: string]: any

  constructor(data?: DepositRule) {
    this.init(data)
  }
}

DepositRule.prototype.init = function init(data?: DepositRule) {
  this.id = get(data, 'id')
  this.hotel_id = get(data, 'hotel_id')
  this.code = get(data, 'code', '')
  this.name = get(data, 'name', '')
  this.rule_type = get(data, 'rule_type', '')
  this.amount = get(data, 'amount', 0)
  this.disabled = get(data, 'disabled', false)
  this.sequence = get(data, 'sequence', 1)
  this.created_id = get(data, 'created_id')
  this.updated_id = get(data, 'updated_id')
  this.created_at = get(data, 'created_at')
  this.updated_at = get(data, 'updated_at')
  this.version = get(data, 'version')
}
